
import { executeSql } from '../util/db.js';

export const insertNewComment = function (author, content, articleId) {
    let sql = "insert into comments values (null,?,?,curdate(),curtime(),'待审核',? )";
    return executeSql(sql, [author, content, articleId])
}
export const selectComment = function (articleId) {
    let sql = "select author,date,content from comments where articleId=?";
    return executeSql(sql, [articleId])
}
//文章评论搜索
export const selectCommentSearch = function (page, perpage) {
    let sql = "select id,author,content,date from comments limit ?,?";
    let offset = (page - 1) * perpage;
    return executeSql(sql, [offset, parseInt(perpage)])
}